package com.neu.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class JDBCUtil {
	private static String url="jdbc:mysql://localhost:3306/mjq";
	 private static String userName="root";
	 private static String pass="mysql";
	 private static String driver="com.mysql.jdbc.Driver";
	 private static Connection conn;
	 
	 public static Connection getConn() throws ClassNotFoundException, SQLException {
		 Class.forName(driver);
		 conn=DriverManager.getConnection(url, userName, pass);
		 return conn;
	 }
	 
	 public static void close(Connection conn,PreparedStatement ps,ResultSet rs) throws SQLException {
		
		 if(conn!=null) {
			 conn.close();
		 }
		 if(ps!=null) {
			 ps.close();
		 }
		 if(rs!=null) {
			 rs.close();
		 }
	 }
}